﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Einstein.Data;
using Einstein.Group.BLL;

namespace Einstein.Group.Model
{
    public class DeviceInfoModel :DeviceInfo
    {
        public string DevicePlace
        {
            get
            {
                var dic = DictionaryBLL.GetByCategoryAndKeyValue("设备位置", this.DevicePlaceID);
                if (dic != null)
                {
                    return dic.KeyName;
                }
                return null;
            }
        }

        public string DeviceDeptName
        {
            get 
            {
                return "未知";
            }
        }

        public string DeviceType
        {
            get 
            {
                var dic = DictionaryBLL.GetByCategoryAndKeyValue("设备类型", this.DeviceTypeID);
                if (dic != null)
                {
                    return dic.KeyName;
                }
                return null;
            }
        }

        public string ConnectTypeName
        {
            get
            {
                var dic = DictionaryBLL.GetByCategoryAndKeyValue("通讯类型", this.ConnectType);
                if (dic != null)
                {
                    return dic.KeyName;
                }
                return null;
            }
        }

        public static DeviceInfoModel Load(DeviceInfo info)
        {
            return new DeviceInfoModel()
            {
                ConnectType = info.ConnectType,
                DefaultGateway = info.DefaultGateway,
                Desc = info.Desc,
                DeviceDeptID = info.DeviceDeptID,
                DeviceNO = info.DeviceNO,
                DevicePlaceID = info.DevicePlaceID,
                DeviceTypeID = info.DeviceTypeID,
                IP = info.IP,
                Port = info.Port,
                SubnetMask = info.SubnetMask,
            };
        }

    }
}
